import {nanoid} from  'nanoid'
import CImg from '@/assets/images/symbol_c_img.svg'
import AddImg from '@/assets/images/symbol_add_img.svg'
import ReduceImg from '@/assets/images/symbol_reduce_img.svg'
import RideImg from '@/assets/images/symbol_ride_img.svg'
import DividerImg from '@/assets/images/symbol_divider_img.svg'

import CActiveImg from '@/assets/images/symbol_c_active_img.svg'
import AddActiveImg from '@/assets/images/symbol_add_active_img.svg'
import ReduceActiveImg from '@/assets/images/symbol_reduce_active_img.svg'
import RideActiveImg from '@/assets/images/symbol_ride_active_img.svg'
import DividerActiveImg from '@/assets/images/symbol_divider_active_img.svg'

export const IndexTree = <any>{
    more: [
        {
            type: 'offLine',
            name: '下线'
        },
        {
            type: 'auth',
            name: '授权'
        },
        {
            type: 'share',
            name: '分享'
        },
        {
            type: 'delete',
            name: '删除'
        },
    ]
}

export const ADNOR = [
    {
        label: 'and',
        value: 'AND'
    },
    {
        label: 'or',
        value: 'OR'
    }
]
export const CONTAIN = [
    {
        label: '包含',
        value: 'IN'
    },
    {
        label: '不包含',
        value: 'NOT_IN '
    }
]

export const PERIOD = [
    {
        label: '天',
        value: 'DAY'
    },
    {
        label: '周',
        value: 'WEEK'
    },
    {
        label: '月',
        value: 'MONTH'
    },{
        label: '季',
        value: 'QUARTER'
    }
]
export enum Priod {
    'DAY' = '天',
    'WEEK' = '周',
    'MONTH' = '月',
    'QUARTER' = '季'
  }
export enum StaticTime {
    'DAY' = 'DAY',
    'WEEK' = 'WEEK',
    'MONTH' = 'MONTH',
    'QUARTER' = 'QUARTER',
    'RECENT' = 'DAY',
    'WEEK_TO_NOW' = 'DAY',
    'MONTH_TO_NOW' = 'DAY',
    'YEAR_TO_NOW' = 'DAY',
}
export const SOMETIME = [
    {
        label: '当日',
        value: 'DAY'
    },
    {
        label: '当周',
        value: 'WEEK'
    },
    {
        label: '当月',
        value: 'MONTH'
    },
    {
        label: '当季',
        value: 'QUARTER'
    },
    {
        label: '最近',
        value: 'RECENT'
    },
    {
        label: '周至今',
        value: 'WEEK_TO_NOW'
    },
    {
        label: '月至今',
        value: 'MONTH_TO_NOW'
    },
    {
        label: '年至今',
        value: 'YEAR_TO_NOW'
    }
]

export const DATEMODE:any = [
    {
        label: '今天',
        value: 'TODAY'
    },
    {
        label: '之前',
        value: 'BEFORE'
    },
    {
        label: '固定日期',
        value: 'FIXDATE'
    }
]

export const INDEXDATEMODE :any = [
    {
        label: '相对日期',
        value: 'BEFORE'
    },
    {
        label: '固定日期',
        value: 'FIXDATE'
    }
]
// 对比值
export const COMPAREVALUE = [
    {
        label: '对比值数值',
        value: 'VAL',
    },
    {
        label: '差值百分比',
        value: 'GAPPERCENT'
    },
    {
        label: '差值',
        value: 'GAPVAL'
    }
]
export enum CompareType {
    'VAL' = '对比值数值',
    'GAPPERCENT' = '差值百分比',
    'GAPVAL' = '差值',
}

export const NUMBERUNIT = [
    {
        label: '个',
        value: 'GE',
    },
    {
        label: '万',
        value: 'WAN',
    },
    {
        label: '亿',
        value: 'YI',
    },
    {
        label: '百分比',
        value: 'PERCENT',
    },
]
export enum NumberUnit {
    'WAN' = '万',
    'YI' = '亿',
}

export enum NumberValue {
    'GE' = 1,
    'WAN' = 10000,
    'YI' = 100000000,
    'PERCENT' = 0.01
}

export const relationShip = [
    {
        symbol: 'c',
        name: '因果关系',
        index: 0,
        id: nanoid(10),
        type: 'symbolCard',
        img: CImg,
        activeImg: CActiveImg,
        correlation: true
    },
    {
        symbol: '＋',
        name: '相加关系',
        index: 1,
        id: nanoid(10),
        type: 'symbolCard',
        img: AddImg,
        activeImg: AddActiveImg
    },
    {
        symbol: '－',
        name: '相减关系',
        index: 2,
        id: nanoid(10),
        type: 'symbolCard',
        img: ReduceImg,
        activeImg: ReduceActiveImg
    },
    {
        symbol: '×',
        name: '相乘关系',
        index: 3,
        id: nanoid(10),
        type: 'symbolCard',
        img: RideImg,
        activeImg: RideActiveImg
    },
    {
        symbol: '÷',
        name: '相除关系',
        index: 4,
        id: nanoid(10),
        type: 'symbolCard',
        img: DividerImg,
        activeImg: DividerActiveImg
    }
]

interface ListValueI {
    dimId: string;
    dimName: string;
    opType: undefined | string;
    fieldName: undefined | string;
    values: Array<String>;
}
interface PriodValueI {
    type: string,
    offset: number,
    timeUnit: string
}
export const defaultConfig :{
    cardName: string | undefined;
    compare: any;
    compareValue: string | undefined;
    dateCondition: any;
    gapValue: string | undefined;
    keys: string | undefined;
    metricsId: string | number | undefined;
    metricsName: string | undefined;
    metricsSetting: {
        metricsConditions: Array<ListValueI> | undefined;
        statisticalPeriod: PriodValueI;
        rela: string;
        numberFormat: string;
    };
    target: number | undefined;
    value: string | undefined
} = {
        cardName: '',
        compare: {
            compareName: '',
            compareType: '',
            dateCondition: {
                dateMode: '',
                offset: undefined,
                fixDate: undefined,
                timeUnit: ''
            }
        },
        compareValue: '',
        dateCondition: {
            dateMode: 'BEFORE',
            fixDate: '',
            offset: 1,
            timeUnit: ''
        },
        gapValue: '',
        keys: undefined,
        metricsId: undefined,
        metricsName: undefined,
        metricsSetting: {
            metricsConditions: [],
            rela: 'AND',
            numberFormat: 'GE',
            statisticalPeriod: {
                type: 'DAY',
                offset: 1,
                timeUnit: 'DAY'
            },
        },
        target: undefined,
        value: undefined

}